import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { BalanceRecordVO, BalanceRecordForm, BalanceRecordQuery } from '@/api/device/balanceRecord/types';

/**
 * 查询用户余额操作记录列表
 * @param query
 * @returns {*}
 */

export const listBalanceRecord = (query?: BalanceRecordQuery): AxiosPromise<BalanceRecordVO[]> => {
  return request({
    url: '/device/balanceRecord/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询用户余额操作记录详细
 * @param balanceRecordId
 */
export const getBalanceRecord = (balanceRecordId: string | number): AxiosPromise<BalanceRecordVO> => {
  return request({
    url: '/device/balanceRecord/' + balanceRecordId,
    method: 'get'
  });
};

/**
 * 新增用户余额操作记录
 * @param data
 */
export const addBalanceRecord = (data: BalanceRecordForm) => {
  return request({
    url: '/device/balanceRecord',
    method: 'post',
    data: data
  });
};

/**
 * 修改用户余额操作记录
 * @param data
 */
export const updateBalanceRecord = (data: BalanceRecordForm) => {
  return request({
    url: '/device/balanceRecord',
    method: 'put',
    data: data
  });
};

/**
 * 删除用户余额操作记录
 * @param balanceRecordId
 */
export const delBalanceRecord = (balanceRecordId: string | number | Array<string | number>) => {
  return request({
    url: '/device/balanceRecord/' + balanceRecordId,
    method: 'delete'
  });
};
